﻿@model Sheng.WeixinConstruction.Management.Shell.Models.PointCommodityOrderDetailViewModel

@{
    ViewBag.Title = "PointCommodityOrderDetail";
    Layout = "~/Views/Shared/_LayoutBlank.cshtml";
}

<style>
    .imgPointCommodity {
        max-height: 70px;
        max-width: 90%;
        vertical-align: middle;
    }
</style>



<script type="text/javascript">

    $(document).ready(function ()
    {
        var status = @((int)Model.Order.Status);
        if(status == 1){
            $("#btnDeal").show();
        }
        else{
            $("#btnDeal").hide();
        }
    });

    function deal()
    {
        var loadLayerIndex = layer.load(0, {
            shade: [0.2, '#fff']
        });

        $.ajax({
            url: "/Api/PointCommodity/DealPointCommodityOrder?id=@Model.Order.Id",
            type: "POST",
            dataType: "json",
            success: function (data, status, jqXHR)
            {
                layer.close(loadLayerIndex);
                if (data.Success)
                {
                    //0 成功 1未知状态 2该订单已发货过 3该订单已取消
                    switch(data.Data.Result){
                        case 0:
                            layerAlert("成功！",refresh);
                            break;
                        case 2:
                            layerAlert("该订单已发货过，不能再次发货。");
                            break;
                        case 3:
                            layerAlert("该订单已被取消，不能发货。");
                            break;
                        default:
                            layerAlert("订单状态无效。");
                            break;
                    }

                } else
                {
                    layerAlert(data.Message);
                }
            },
            error: function (xmlHttpRequest)
            {
                layer.close(loadLayerIndex);
                alert("Error: " + xmlHttpRequest.status);
            }
        });
    }

    function cancel()
    {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }

    function refresh(){
        location.reload();
    }

</script>

<div style="margin-left:20px; margin-right:20px; margin-top:20px;">
    <span id="spanTitle" class="font_black_24">订单详情</span>
</div>

<div style=" background-color:#ccc; margin-left:20px; margin-right:20px; margin-top:10px; height:1px;">

</div>

<div style=" position:absolute; overflow:auto ;margin-top:25px;left:30px; right:30px; bottom:60px; top:50px; ">

    <div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="110" height="36">订单编号：</td>
                <td>@Model.Order.OrderNumber</td>
            </tr>
            <tr>
                <td height="36">会员昵称：</td>
                <td>@Model.Member.NickName</td>
            </tr>
            <tr>
                <td height="36">下单时间：</td>
                <td>@Model.Order.OrderTime</td>
            </tr>
            <tr>
                <td height="36">积分：</td>
                <td>@Model.Order.Point</td>
            </tr>
            <tr>
                <td height="36">金额：</td>
                <td>@(Model.Order.Price / 100f)</td>
            </tr>
            <tr>
                <td height="36">当前状态：</td>
                <td>@Model.Order.StatusString</td>
            </tr>
        </table>
    </div>
    <div style="margin-top:10px;">
        订单商品：
    </div>
    <div style="margin-top:10px;">
        @foreach (var item in Model.ItemList)
        {
            <div style="margin-top:10px;">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="140" height="36" align="center" valign="top">
                            <img src="@item.ImageUrl" class="imgPointCommodity" />
                        </td>
                        <td valign="top">
                            <div>
                                <div>@item.Name</div>
                                <div style="margin-top:5px;">
                                    <span>数量：@item.Quantity</span><span style="margin-left:10px;">( @(item.Price * item.Quantity / 100f) 元 + @(item.Point * item.Quantity) 积分 )</span>
                                </div>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        }
    </div>
</div>

<div style=" background-color:#ccc; position:absolute; bottom:55px; left:20px;right:20px; height:1px;">

</div>

<div style="position:absolute; bottom:15px; left:20px;right:20px;">


    <div style="float:left;">
        <input id="btnDeal" name="btnDeal" type="button" class="btn_green" style="width:200px" value="发 货" onclick="deal()" />
    </div>

    <div style="float:right">
        <input id="btnClose" name="btnClose" type="button" class="btn_blue" value="关 闭" onclick="cancel()" />
    </div>
    <div style="clear:both">
    </div>
</div>